package com.xqb.listen.ui.theme

import android.app.Activity
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.LocalOverscrollConfiguration
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.platform.LocalView
import androidx.core.view.WindowCompat

private val DarkColorScheme = darkColorScheme(
    primary = White90,
    secondary = White70,
    tertiary = White50
)

private val LightColorScheme = lightColorScheme(
    primary = Black90,
    secondary = Black70,
    tertiary = Black50,
)

@OptIn(ExperimentalFoundationApi::class)
@Composable
fun ListenAppComposeTheme(
    darkTheme : Boolean = isSystemInDarkTheme() ,
    content: @Composable () -> Unit
) {
    val view = LocalView.current
    if (!view.isInEditMode) {
        SideEffect {
            val window = (view.context as Activity).window
            WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme
            WindowCompat.getInsetsController(window, view).isAppearanceLightNavigationBars = false
        }
    }
    MaterialTheme(
        colorScheme = DarkColorScheme,
        typography = Typography,
        content = {
            //移除全局滑动超出效果
            CompositionLocalProvider(
                values = arrayOf(LocalOverscrollConfiguration provides null),
                content = content
            )
        }
//        content = content
    )
}

